#ifndef PRACTICE6_H_INCLUDED
#define PRACTICE6_H_INCLUDED
#include<list>
using namespace std;
void joseph(list<int>& mylist, int n , int m )
{

    for(int i = 1; i < n + 1; ++i)
    {
        mylist.push_back(i);
    }

    list<int>::iterator itr = mylist.begin();

    int addcount = 0;

    while(mylist.size() > 0)
    {
            while(addcount < m)
            {
                if(++itr != mylist.end())
                {

                }
                else{
                   itr = mylist.begin();
                }

                ++addcount;
            }

            cout << "erase " << *itr << endl;

            itr = mylist.erase(itr);



            if(itr == mylist.end() && mylist.size()>0)
            {
                itr = mylist.begin();
            }


            addcount = 0;



    }


}


#endif // PRACTICE6_H_INCLUDED
